package com.snail.controller;

import com.snail.service.SecKillService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 【swg】.
 * @Date 2017/12/12 14:15
 * @DESC
 * @CONTACT 317758022@qq.com
 */
@RestController
@RequestMapping("/skill")
@Slf4j
public class SeckillController {
    @Autowired
    private SecKillService secKillService;

    /**
     * 查询秒杀的结果
     * @param productId
     * @return
     * @throws Exception
     */
    @GetMapping("/query/{productId}")
    public String query(@PathVariable String productId) throws Exception{
        return secKillService.querySecKillProductInfo(productId);
    }

    /**
     * 秒杀
     * @param productId
     * @return
     * @throws Exception
     */
    @GetMapping("/order/{productId}")
    public String skill(@PathVariable String productId) throws Exception{
        secKillService.orderProductMockDiffUser(productId);
        return secKillService.querySecKillProductInfo(productId);
    }
}
